import { handleChartData } from '../echartUtils.js'
export function getLineOption(dataList) {

	let { seriesList, axisDataList } = handleChartData(dataList);

	seriesList = seriesList.map((item, index) => {
		//这个地方需要处理特殊数据
		let dataList = [...item.data];
		dataList.forEach(itemData => {
			if (itemData.value != 0) {
				itemData.symbol = "circle";
				itemData.itemStyle = {
					color: "#ffd946"
				}
			}
		});
		let result = {
			"type": "line",
			"name": item.name,
			"symbolSize": 4,
			"yAxisIndex": 0,
			"label": {
				"show": false,
			},
			"itemStyle": {
				"color": "#959595"
			},
			"data": item.data,
		};
		return result;
	});
	let option = {
		"textStyle": {
			"fontFamily": "OPPOSans"
		},
		"tooltip": {
			"show": false
		},
		"grid": {
			"top": 20,
			"bottom": 20,
			"left": 20,
			"right": 20,
			"containLabel": true
		},
		"legend": {
			"show": false,
			"top": "top",
			"left": "right",
			"orient": "horizontal",
			"selectedMode": true,
			"textStyle": {
				"fontSize": 12,
				"color": "rgba(153, 153, 153, 1)",
				"fontFamily": "Source Han Sans CN",
				"fontWeight": "normal"
			},
			"type": "plain",
			"width": "auto",
			"height": "auto",
		},
		"xAxis": [{
			"show": true,
			"type": "category",
			"alignTicks": true,
			"inverse": false,
			"nameTextStyle": {
				"padding": ["0", "0", "0", "-40"],
				"fontSize": 12,
				"color": "rgba(153, 153, 153, 1)",
				"fontWeight": "normal"
			},
			"axisLine": {
				"show": false,
			},
			"axisTick": {
				"show": false,
			},
			"axisLabel": {
				"show": true,
				"margin": 10,
				"fontSize": 12,
				"color": "rgba(153, 153, 153, 1)",
				"fontWeight": "normal"
			},
			"splitLine": {
				"show": false,
				"lineStyle": {
					"type": "solid",
					"width": 1,
					"color": "rgba(153, 153, 153, 1)"
				}
			},
			"data": axisDataList
		}],
		"yAxis": [{
			"show": true,
			"type": "value",
			"axisLine": {
				"show": false,
			},
			"axisTick": {
				"show": false,
			},
			"boundaryGap": ["0%", "0%"],
			"axisLabel": {
				"show": true,
				"margin": 10,
				"fontSize": 12,
				"color": "rgba(153, 153, 153, 1)",
				"fontWeight": "normal",
			},
			"splitLine": {
				"show": true,
				"lineStyle": {
					"type": "solid",
					"width": 1,
					"color": "rgba(104, 114, 142, 0.2)"
				}
			},
			"splitNumber": null,
			"data": []
		}],
		"series": seriesList,
		"animation": true,
		"animationDuration": 1000,
		"animationEasing": "cubicOut",
		"animationDelay": 0
	}
	return option;
}